<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/16 0016
 * Time: 13:59
 */
namespace app\validate;

use think\Validate;

class Work extends Validate
{
    protected $rule =   [
        'title'  => 'require|max:100',
        'type'   => 'number|in:0,1,2,3,4,5',
//        'img_url' => 'file|fileMime:image/png,image/jpeg,image/gif,image/x-png|fileSize:2097152',
//        'sm_img' => 'file|fileMime:image/png,image/jpeg,image/gif,image/x-png|fileSize:2097152',
        'status' => 'number|in:0,1',
        'content' => 'require|min:10'
    ];

    protected $message  =   [
        'title.require' => '标题必须填写',
        'name.max'     => '标题最多不能超过100个字符',
        'type.number'   => '类型格式错误',
        'type.in'   => '类型不存在',
        'img_url.file' => '必须是文件!',
        'img_url.fileMime' => '必须是图片并且小于2兆',
        'sm_img.file' => '必须是文件',
        'sm_img.fileMime' => '必须是图片并且小于2兆',
        'status.number' => '状态格式错误',
        'status.in' => '状态不正确',
        'content.require' => '描述必须填写',
        'content.min' => '最少10个字符'
    ];

    protected $scene = [
        'add'  =>  ['title','type','img_url','content'],
    ];
    protected $scene2 = [
        'add'  =>  ['sm_img','type','status'],
    ];

}